// const {
// 	db,
// 	dbCmd,
// 	$,
// 	result_success,
// 	result_error,
// 	appletInfoCollection,
// 	shopieCollection,
// 	userCollection
// } = require('../../common/constants')
// module.exports = async function(params = {}) {
// 	const token = this.getUniIdToken()
// 	if (!token) {
// 		return result_error('登录失效,请重新登录')
// 	}
// 	let payload = await this.uniID.checkToken(token)
// 	if (payload.code) {
// 		return payload
// 	}
// 	let cUser = await userCollection.doc(payload.uid).get()
// 	cUser = cUser.data[0]
// 	//获取当前应用
// 	let appletInfoData = await appletInfoCollection.doc(cUser.app_id).get()
// 	appletInfoData = appletInfoData.data[0]
// 	let queryType = params.queryType
// 	let startDate = params.startDate
// 	let endDate = params.endDate
// 	let startDateTime;
// 	let endDateTime;
// 	let timezone = 8;
// 	let calDateTime = timezone * 60 * 60 * 1000;
// 	if (startDate) {
// 		if (!endDate) {
// 			endDate = startDate
// 		}
// 		startDate = new Date(startDate + ' 00:00:00');
// 		endDate = new Date(endDate + ' 23:59:59'); 
// 		if (startDate && startDate.toString().indexOf('UTC') > -1) {
// 			startDateTime = startDate.getTime() - calDateTime;
// 			endDateTime = endDate.getTime() - calDateTime;
// 		} else {
// 			startDateTime = startDate.getTime();
// 			endDateTime = endDate.getTime();
// 		}
		
// 	} else {
// 		let cDate = new Date()
// 		if (cDate && cDate.toString().indexOf('UTC') > -1) {
// 			cDate.setHours(cDate.getHours() + 8)
// 		}
// 		let cYear = cDate.getFullYear();
// 		let cMonth = cDate.getMonth() + 1;
// 		let cDay = cDate.getDate();
// 		startDate = new Date(cYear + "-" + cMonth + "-" + cDay + ' 00:00:00');
// 		endDate = new Date(cYear + "-" + cMonth + "-" + cDay + ' 23:59:59');
// 		if (startDate && startDate.toString().indexOf('UTC') > -1) {
// 			startDateTime = startDate.getTime() - calDateTime;
// 			endDateTime = endDate.getTime() - calDateTime;
// 		} else {
// 			startDateTime = startDate.getTime();
// 			endDateTime = endDate.getTime();
// 		}
// 	}
	
// 	let queryShopieTotal = {
// 		app_id: appletInfoData._id,
// 		shop_id: appletInfoData._id
// 	};
// 	let seriesData = []
// 	let businessTotal = 0
// 	queryShopieTotal.create_time = dbCmd.gte(startDateTime).and(dbCmd.lte(endDateTime))
// 	if (params.type === 'count') {
// 		queryShopieTotal.type = 0
// 		let businessCount = await shopieCollection.aggregate().match(queryShopieTotal).group({
// 			_id: '$_id'
// 		}).limit(1000).end();
// 		let business_count = businessCount.data.length
// 		seriesData.push({
// 			"name": "收款-" + business_count,
// 			"value": business_count
// 		})

// 		queryShopieTotal.type = 1
// 		businessCount = await shopieCollection.aggregate().match(queryShopieTotal).group({
// 			_id: '$_id'
// 		}).limit(1000).end();
// 		business_count = businessCount.data.length
// 		seriesData.push({
// 			"name": "退款-" + business_count,
// 			"value": business_count
// 		})
// 	} else {
// 		queryShopieTotal.type = 0
// 		businessTotal = await shopieCollection.aggregate().match(queryShopieTotal).group({
// 			_id: '$app_id',
// 			total: $.sum('$money')
// 		}).limit(1000).end();
// 		let business_total = 0
// 		if (businessTotal.data[0] && businessTotal.data[0].total) {
// 			business_total = (businessTotal.data[0].total / 100).toFixed(2)
// 		}
// 		seriesData.push({
// 			"name": "收款-" + business_total,
// 			"value": business_total
// 		})

// 		queryShopieTotal.type = 1
// 		businessTotal = await shopieCollection.aggregate().match(queryShopieTotal).group({
// 			_id: '$app_id',
// 			total: $.sum('$money')
// 		}).limit(1000).end();
// 		business_total = 0
// 		if (businessTotal.data[0] && businessTotal.data[0].total) {
// 			business_total = (businessTotal.data[0].total / 100).toFixed(2)
// 		}
// 		seriesData.push({
// 			"name": "退款-" + business_total,
// 			"value": business_total
// 		})

// 	}

// 	let rData = {
// 		"series": [{
// 			"name": "",
// 			"data": seriesData
// 		}]
// 	}
// 	return result_success(rData)
// }